home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / text / edit / FrexxShell.lha / FrexxShell.FPL next >
Text File  |  1995-07-10  |  2KB  |  99 lines

  1. /* FrexxEd Shell Environment
  2.    by Carsten Orthbandt
  3.    $VER: FrexxShell V 1.0 5.7.95
  4.    Read FrexxShell.FPL.README for further information
  5. */
  6.  
  7. int bufferid;
  8. string currentdir;
  9. string cmdfname,outfname,dirfname,errfname;
  10.  
  11. void DoShellCmnd(string cmd)
  12. {
  13.  int errc;
  14.  SaveString(cmdfname,"failat 21\ncd \""+currentdir+"\"\n"+cmd+" <NIL: >"+outfname+"\ncd >"+dirfname+"\n");
  15.  errc=System("Execute >>"+outfname+" "+cmdfname,"",errfname);
  16.  GotoLine(-1,0);
  17.  InsertFile(outfname);
  18.  Output(LoadString(errfname));
  19.  currentdir=LoadString(dirfname);
  20.  currentdir=substr(currentdir,0,strlen(currentdir)-1);
  21.  Output(currentdir+">"); 
  22.  SetInfo(-1,"changes",0);
  23. };
  24.  
  25. export void TabFNC()
  26. {
  27.  int cmndstrt,flns;
  28.  string cmline,flnm,nflnm;
  29.  string files[1];
  30.  int filecnt;
  31.  if (GetBufferID()==bufferid)
  32.  {
  33.   GotoLine(-1,260);
  34.   cmline=GetLine();
  35.   cmndstrt=strstr(cmline,">",0)+1;
  36.   cmline=substr(cmline,cmndstrt,-1);
  37.   flns=strlen(cmline)-1;
  38.   if (flns!=-1){
  39.   while ((flns>=0)&&(cmline[flns] != ' ')&&(cmline[flns] != '\"'))
  40.   {flns--;};flns++;}
  41.   else{flns=0;};
  42.   flnm=substr(cmline,flns,-1);
  43.   cmline=substr(cmline,0,flns);
  44.   if (strlen(flnm)==0){flnm=currentdir;};
  45.   nflnm=flnm;
  46.   filecnt=GetFileList(nflnm+"#?",&files);
  47.   if(RequestWindow("Select File",50,"","A",&files,&nflnm,filecnt))
  48.   {
  49.    cmline=cmline+nflnm;
  50.   }else
  51.   {
  52.    cmline=cmline+flnm;
  53.   }
  54.   GotoLine(-1,cmndstrt);DeleteEol();
  55.   Output(cmline);
  56.  }else
  57.  {
  58.   Output("\t");
  59.  }
  60. }
  61.  
  62. export void ProcessShellCmndLine()
  63. {
  64.  int cmndstrt;
  65.  string cmline;
  66.  cmline=GetLine();
  67.  Output("\n");
  68.  if (GetBufferID()==bufferid)
  69.  {
  70.   GotoLine(-1,260);
  71.   cmndstrt=strstr(cmline,">",0)+1;
  72.   cmline=substr(cmline,cmndstrt,-1);
  73.   if (strlen(cmline)>0)
  74.    {DoShellCmnd(cmline);}else{DoShellCmnd("Echo");};
  75.   System("Delete "+outfname,"","NIL:");
  76.  }
  77. };
  78.  
  79. void SetupFrexxShell()
  80. {
  81.  string bfids;
  82.  AssignKey("ProcessShellCmndLine();","'Enter'");
  83.  AssignKey("TabFNC();","'Tab'");
  84.  currentdir="SYS:";
  85.  bufferid=New();
  86.  Activate(bufferid,1);
  87.  CurrentBuffer(bufferid);
  88.  Rename("FrexxCon");
  89.  bufferid=GetBufferID("FrexxCon");
  90.  bfids=itoa(bufferid);
  91.  cmdfname="T:FShCmd_"+bfids;
  92.  outfname="T:FShOut_"+bfids;
  93.  dirfname="T:FShDir_"+bfids;
  94.  errfname="T:FShErr_"+bfids;
  95.  DoShellCmnd("echo FrexxShell by Carsten Orthbandt");
  96. };
  97.  
  98. SetupFrexxShell();
  99.